package servlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

import hbase.HbaseUtil;
import hbase.Student;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * @author Lu Ruotong
 * @date 2022/3/19 17:23
 */
@WebServlet("/studentQuery5")
public class studentQuery5 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 获取查询参数
        String studentStatus = req.getParameter("studentStatus");
        HbaseUtil hbaseUtil = new HbaseUtil();
        List<Student> display = hbaseUtil.statusQuery(studentStatus);

        resp.setContentType("text/html; charset=UTF-8");
        PrintWriter pw = resp.getWriter();

        for (int i = 0; i < display.size(); i++) {
            pw.write(display.get(i).getName() + " ");
//            pw.write(display.get(i).getStudentStatus()+" ");

        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}